#include <QtTest>
#include <QFile>
#include <QTextStream>
#include <HtmlOptimizer.h>

#include "test_ShowFormatter.h"



ShowFormatter_test::ShowFormatter_test()
{
}

/** executed before every test case */
void ShowFormatter_test::init()
{
}

/** executed after every test case */
void ShowFormatter_test::cleanup()
{
}

void ShowFormatter_test::initTestCase()
{
}

void ShowFormatter_test::cleanupTestCase()
{
}

void ShowFormatter_test::testOptimizer()
{
   QFile  nativeFile( QString(PROJECT_PATH) + "/ShowFormatter/Files/NativeHtml.html");
   nativeFile.open( QFile::ReadOnly);

   QVERIFY( nativeFile.isOpen());

   QTextStream  nativeStream( &nativeFile);
   QString nativeHtml = nativeStream.readAll();
   nativeFile.close();

   QFile  optimizedFile( QString(PROJECT_PATH) + "/ShowFormatter/Files/OptimizedHtml.html");
   optimizedFile.open( QFile::ReadOnly);

   QVERIFY( optimizedFile.isOpen());

   QTextStream  optimizedFileStream( &optimizedFile);
   QString optimizedHtml_compare = optimizedFileStream.readAll();
   optimizedFile.close();

   HtmlOptimizer optimizer;
   QString optimizedHtml_test = optimizer.optimize_html( &nativeHtml);

   QCOMPARE( optimizedHtml_compare, optimizedHtml_test );
}
